cmake_minimum_required(VERSION 3.16) # 指定CMake的最低指定版本

project(2k0300Server LANGUAGES C CXX) # 指定项目名称，语言c/c++

# 指定c和cpp的版本
set(CMAKE_C_STANDARD 99) 
set(CMAKE_CXX_STANDARD 11) 



include_directories(
    ${CMAKE_SOURCE_DIR}/Inc
    ${CMAKE_SOURCE_DIR}/Inc/modbus
) 

# 链接目录：libemqtt.a 所在目录
link_directories(
    ${CMAKE_SOURCE_DIR}/lib
)

set(SOURCES
    main.cpp
    Src/gpioControl.cpp
    Src/ModbusDevice.cpp
    Src/MqttClient.cpp
)

# add_executable(mqtt_demo ${SOURCES})
# add_executable(modbus_demo ${SOURCES})
add_executable(modbus_mqtt_demo ${SOURCES})


target_link_libraries(modbus_mqtt_demo
    pthread
    dl
    m
    ${CMAKE_SOURCE_DIR}/lib/libmosquitto.a
    ${CMAKE_SOURCE_DIR}/lib/libmodbus.a
)


# 链接系统库 + 第三方 MQTT 静态库
# target_link_libraries(mqtt_demo
#     pthread
#     dl
#     m
#     ${CMAKE_SOURCE_DIR}/lib/libmosquitto.a
#     ${CMAKE_SOURCE_DIR}/lib/libmodbus.a
# )

# target_link_libraries(modbus_demo
#     ${CMAKE_SOURCE_DIR}/lib/libmodbus.a
# )

